Common Examples
Amun SDK provides an array of options on how to calculate load factors for a location. Examples below will be using AmunSession.run_load_factor_for_parameters
that expects two parts: base parameters and one of the flow parameters:
AverageWindSpeedParameters
BuiltInWindParameters
PowerDensityParameters
P50ScalingParameters
P50YieldScalingParameters
UploadedWindParameters
WeibullParameters
UploadedGeneration
And to read more information about each wind/power type, refer to the WindType Objects section of SDK Reference.
You can find more examples with code in Amun Python SDK repository inside the examples/
folder.
Time consideration
It will take around 2-15 minutes to complete 1 load factors calculation. There may be times when you need to run 100+ calculations, so it might take a while for your requests to come back. For such cases, we have more advanced functions that allow you submit calculations in a batch which will speed up the total time of calculations. See Advanced Examples to see how it works
Calculate Load Factors with Amun Wind Atlas
To use AmunSession.run_load_factor_for_parameters
, select an available turbine that is available in Amun and set base parameters. See SDK Reference for explanations on what each parameter means.
Built-in dataset is a good choice of wind type to use if no site-specific data is available. To use a built-in datase, use aurora.amun.client.parameters.BuiltInWindParameters(WindType)
. You can pass types like AuroraWindAtlas
, Era5
, Merra2
, or NEWA
. But check whether the wind type is supported by the region.
In our case, the region support Amun Wind Atlas, which is the most accurate version of built-in wind data available in Amun
from aurora.amun.client.session import AmunSession
from aurora.amun.client.parameters import (
BuiltInWindParameters,
LoadFactorBaseParameters
)
session = AmunSession()
turbine = session.get_turbine_by_name("Siemens SWT-4.0-130")
base_parameters = LoadFactorBaseParameters(
turbineModelId=turbine["id"],
latitude=59.59,
longitude=0,
startTimeUTC="2018-01-01T00:00:00.000Z",
regionCode="GBR",
hubHeight=90,
lossesAvailability=0.1,
lossesWake=0,
numberOfTurbines=12,
usePowerCurveSmoothing=False
)
flow_parameters = BuiltInWindParameters("AuroraWindAtlas", True)
print("Running load factor calculation. This will take a few minutes...")
load_factors = session.run_load_factor_for_parameters(
flow_parameters, base_parameters
)
# Print out the wind type and first 5 hourly load factors
print("Example load factors for wind type:", load_factors["parameters"]["windType"])
print(load_factors["weatherYearHourly"][:5])
Expected output
Example load factors for wind type: AuroraWindAtlas
[{'dateTime': '2018-01-01T00:00Z', 'windSpeed': 8.330645528908647, 'loadFactor': 0.5154}, {'dateTime': '2018-01-01T01:00Z', 'windSpeed': 7.447324082608763, 'loadFactor': 0.3733}, {'dateTime': '2018-01-01T02:00Z', 'windSpeed': 7.131573353874345, 'loadFactor': 0.3252}, {'dateTime': '2018-01-01T03:00Z', 'windSpeed': 8.044216007075045, 'loadFactor': 0.4654}, {'dateTime': '2018-01-01T04:00Z', 'windSpeed': 8.72793935280024, 'loadFactor': 0.5847}]
Calculate Load Factors with Custom Wind Data
The same code template can be used with other wind types. But for Uploaded Wind, for example, you might want to import a local JSON file with wind speeds. Use get_json
from Amun SDK utilities to load local file
from aurora.amun.client.session import AmunSession
from aurora.amun.client.parameters import (
SpeedAtHeight,
UploadedWindParameters,
LoadFactorBaseParameters
)
from aurora.amun.client.utils import get_json
session = AmunSession()
turbine = session.get_turbine_by_name("Siemens SWT-4.0-130")
base_parameters = LoadFactorBaseParameters(
turbineModelId=turbine["id"],
latitude=59.59,
longitude=0,
startTimeUTC="2017-01-01T00:00:00.000Z",
regionCode="GBR",
hubHeight=90,
lossesAvailability=0.1,
lossesWake=0,
numberOfTurbines=12,
usePowerCurveSmoothing=False
)
# Provide the path to your file
# In our example, the file looks like {"speeds":[10.888, 11.59, ...]}
# and contains 8760 values - for each hour in a year 2017
speeds = get_json("examples\data\example_windSpeed.json")["speeds"]
# Insert the speeds as a SpeedAtHeight object for UploadedWindParameters
flow_parameters = UploadedWindParameters(
uploadedWindStartTime="2017-01-01T00:00:00.000Z",
lowHeight=SpeedAtHeight(10, speeds=speeds),
granularityInMins=60,
)
print("Running load factor calculation. This will take a few minutes...")
load_factors = session.run_load_factor_for_parameters(
flow_parameters, base_parameters
)
# Print out the wind type and first 5 hourly load factors
print("Example load factors for wind type:", load_factors["parameters"]["windType"])
print(load_factors["weatherYearHourly"][:5])
Example load factors for wind type: UploadedWind
[{'dateTime': '2017-01-01T00:00Z', 'windSpeed': 12.476777004018876, 'loadFactor': 0.8987}, {'dateTime': '2017-01-01T01:00Z', 'windSpeed': 13.354024977064322, 'loadFactor': 0.9}, {'dateTime': '2017-01-01T02:00Z', 'windSpeed': 12.738090910135982, 'loadFactor': 0.8994}, {'dateTime': '2017-01-01T03:00Z', 'windSpeed': 12.914630833546354, 'loadFactor': 0.8998}, {'dateTime': '2017-01-01T04:00Z', 'windSpeed': 12.017396341735259, 'loadFactor': 0.8976}]
Calculate Load Factors with P50 scaling + Save to JSON
You might want to save the load factors in a file. And for that you could either use Python's json API json.dump()
or Amun SDK's save_to_json
function. For example, you can save a P50 scaling calculation giving it a timestamp, wind type and unique id for reference.
from aurora.amun.client.session import AmunSession
from aurora.amun.client.parameters import (
P50ScalingParameters,
LoadFactorBaseParameters
)
from aurora.amun.client.utils import save_to_json
from datetime import datetime
session = AmunSession()
turbine = session.get_turbine_by_name("Siemens SWT-4.0-130")
base_parameters = LoadFactorBaseParameters(
turbineModelId=turbine["id"],
latitude=59.59,
longitude=0,
startTimeUTC="2018-01-01T00:00:00.000Z",
regionCode="GBR",
hubHeight=90,
lossesAvailability=0.1,
lossesWake=0,
numberOfTurbines=12,
usePowerCurveSmoothing=False
)
flow_parameters = P50ScalingParameters(p50GrossProduction=0.6)
print("Running load factor calculation. This will take a few minutes...")
load_factors = session.run_load_factor_for_parameters(
flow_parameters, base_parameters
)
timestamp = datetime.now().isoformat().replace(':','_')
save_to_json(
f"load_factors_{timestamp}_{flow_parameters.windType}.json",
load_factors
)
You will find the output in the new directoty called 'out' (will be created in the same folder where you run the script from). And the output file's name will look like this: load_factors_2023-10-06T10_01_09.965295_WindType.P50Scaling.json
.
Calculate Load Factors from Average Wind Speed
Average Wind Speed is another type of calibration Amun SDK has available. See wind type overview for context, and parameters documentation to see which values need to be provided
from aurora.amun.client.session import AmunSession
from aurora.amun.client.parameters import (
AverageWindSpeedParameters,
LoadFactorBaseParameters
)
from aurora.amun.client.utils import save_to_json
session = AmunSession()
turbine = session.get_turbine_by_name("Siemens SWT-4.0-130")
base_parameters = LoadFactorBaseParameters(
turbineModelId=turbine["id"],
latitude=59.59,
longitude=0,
startTimeUTC="2018-01-01T00:00:00.000Z",
regionCode="GBR",
hubHeight=90,
lossesAvailability=0.1,
lossesWake=0,
numberOfTurbines=12,
usePowerCurveSmoothing=False
)
flow_parameters = AverageWindSpeedParameters(averageWindSpeed=10, measurementHeight=40)
load_factors = session.run_load_factor_for_parameters(
flow_parameters, base_parameters
)
# Print out the wind type and first 5 hourly load factors
print("Example load factors for wind type:", load_factors["parameters"]["windType"])
print(load_factors["weatherYearHourly"][:5])
Calculate Load Factors from Collected Production Data
Sometimes you will need to provide sizeable data to Amun SDK. In these cases, it is convenient to use one of the utils of Amun SDK: get_json
. Below is an example for Time Series Generation upload. The process includes an extra step of uploading the generation data to Amun before running valuation.
Make sure that the format of the data is correct and that the generation values have been produced in the location that you pass in valuation parameters. If there is a large discrepancy between the generation values and the long-term reanalysis data in that location Amun API will throw and error.
Because the generation data has already been provided, it is not necessary to specify a turbine.
from aurora.amun.client.parameters import LoadFactorBaseParameters, UploadedGenerationParameters
from aurora.amun.client.session import AmunSession
from aurora.amun.client.utils import get_json, save_to_json
session = AmunSession()
region = "gbr"
longitude = 7.774
latitude = 55.019
hub_height = 120
generation_array = get_json("examples/data/example_loadfactor_generation_request.json")["uploadedGeneration"]
generation_start_time_utc = "2015-12-31T23:00:00.000Z"
start_time_utc = "2013-01-01T00:00:00.000Z"
installed_capacity = 288
granularity_in_mins = 60
use_power_curve_smoothing = False
flow_parameters = UploadedGenerationParameters(
uploadedGeneration = generation_array,
uploadGenerationStartTime = generation_start_time_utc,
installedCapacity = installed_capacity,
granularityInMins = granularity_in_mins
)
base_parameters = LoadFactorBaseParameters(
latitude = latitude,
longitude = longitude,
startTimeUTC = start_time_utc,
regionCode = region,
hubHeight = hub_height,
usePowerCurveSmoothing = use_power_curve_smoothing
)
## Ensure version is set to 2, as Version 1 of the API does not support UplodedGeneration for LoadFactor
loadfactor = session.run_load_factor_for_parameters(flow_parameters, base_parameters, version=2)
save_to_json(f"loadfactor/loadfactor_{loadfactor['parameters']['loadFactorRequestId']}.json", loadfactor)
If you want to know how to run larger number of calculations more effectively, check the Advanced Features on the next page